import os, sys
import pygame
from pygame.locals import *
from state import *

"""inputState class will house events for key presses"""

class inputState():
    
    #keymap bools, these will be true if pressed
    #To add a new input event, add a flag and add a check for the relevent keys in the Update() check
    cancel = False
    accept = False
    up = False
    down = False
    left = False
    right = False
    sword = False
    
    def Update(self): #Grab latest events and fire flags
        self.cancel = False
        self.accept = False
        self.up = False
        self.down = False
        self.left = False
        self.right = False
        self.sword = False
    
        for event in pygame.event.get():
            if event.type == QUIT:       #On Quit
                pygame.quit()
                sys.exit()
            if event.type == KEYDOWN:    #KEYDOWN Events
                if event.key == K_SPACE:
                    self.sword = True
                if (event.key == K_KP_ENTER) or (event.key == K_RETURN):
                    self.accept = True
                if event.key == K_ESCAPE:
                    self.cancel = True
                if ((event.key == K_UP) or (event.key == K_w)):
                    self.up = True
                if ((event.key == K_DOWN) or (event.key == K_s)):
                    self.down = True
                if ((event.key == K_LEFT) or (event.key == K_a)):
                    self.left = True
                if ((event.key == K_RIGHT) or (event.key == K_d)):
                    self.right = True

InputState = inputState()